package com.panasonic.web.service.impl;

import com.panasonic.web.domain.cms.CmsPermission;
import com.panasonic.web.domain.cms.CmsUser;
import com.panasonic.web.mapper.CmsPermissionMapper;
import com.panasonic.web.service.ICmsPermissionService;
import com.panasonic.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * 全新啊Service业务层处理
 *
 * @author lwf
 * @date 2021-11-13
 */
@Service
public class CmsPermissionServiceImpl implements ICmsPermissionService {
    @Autowired
    private CmsPermissionMapper cmsPermissionMapper;


    /**
     * 查询全新啊
     *
     * @param id 全新啊ID
     * @return 全新啊
     */
    @Override
    public CmsPermission selectCmsPermissionById(Long id) {
        return cmsPermissionMapper.selectCmsPermissionById(id);
    }

    /**
     * 查询全新啊列表
     *
     * @param cmsPermission 全新啊
     * @return 全新啊
     */
    @Override
    public List<CmsPermission> selectCmsPermissionList(CmsPermission cmsPermission) {
        return cmsPermissionMapper.selectCmsPermissionList(cmsPermission);
    }

    /**
     * 新增全新啊
     *
     * @param cmsPermission 全新啊
     * @return 结果
     */
    @Override
    public int insertCmsPermission(CmsPermission cmsPermission) {
        return cmsPermissionMapper.insertCmsPermission(cmsPermission);
    }

    /**
     * 修改全新啊
     *
     * @param cmsPermission 全新啊
     * @return 结果
     */
    @Override
    public int updateCmsPermission(CmsPermission cmsPermission) {
        cmsPermission.setUpdateTime(DateUtils.getNowDate());
        return cmsPermissionMapper.updateCmsPermission(cmsPermission);
    }

    /**
     * 批量删除全新啊
     *
     * @param ids 需要删除的全新啊ID
     * @return 结果
     */
    @Override
    public int deleteCmsPermissionByIds(Long[] ids) {
        return cmsPermissionMapper.deleteCmsPermissionByIds(ids);
    }

    /**
     * 删除全新啊信息
     *
     * @param id 全新啊ID
     * @return 结果
     */
    @Override
    public int deleteCmsPermissionById(Long id) {
        return cmsPermissionMapper.deleteCmsPermissionById(id);
    }

    @Override
    public Set<String> getMenuPermission(CmsUser user) {
        return cmsPermissionMapper.selectCmsPermissionByUserId(user.getId());
    }
}
